﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace Chapter12
{
    using Chapter12.View;

    /// <summary>
    /// 第12章 形状、画刷和变换
    /// MainWindow.xaml 的交互逻辑
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();

            #region 01 理解形状
            /*
             * 01 Shape 类
             * 02 矩形和椭圆
             * 03 改变形状的尺寸和放置形状
             * 04 使用 Viewbox 控件缩放形状
             * 05 直线
             * 06 折线
             * 07 多边形
             * 08 直线线帽直线交点
             * 09 点划线
             * 10 像素对齐
             * */
            #endregion

            #region 02 画刷
            /*
             * 01 SolidColorBrush 画刷
             * 02 LinearGradientBrush 画刷
             * 03 RadialGradientBrush 画刷
             * 04 ImageBrush 画刷
             * 05 平铺 ImageBrush 画刷
             * 06 VisualBrush 画刷
             * 07 BitmapCacheBrush 画刷
             * */
            #endregion

            #region 03 变换
            /*
             * 01 变换形状
             * 02 变换元素
             * */
            #endregion

            #region 04 透明
            /*
             * 01 使元素半透明
             * 02 透明掩码
             * */
            #endregion
        }

        private void CommandBinding_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            if (e.Command == ApplicationCommands.Open)
            {
                var button = e.Source as Button;
                if (button != null)
                {
                    if (button == button1)
                    {
                        Demo(new ShapesWindow());
                    }
                    if (button == button2)
                    {
                        Demo(new RoundedRectanglesWindow());
                    }
                    if (button == button3)
                    {
                        Demo(new FillModesWindow());
                    }
                    if (button == button4)
                    {
                        Demo(new ViewboxWindow());
                    }
                }
            }
        }

        private void Demo(Window window)
        {
            window.Owner = this;
            window.WindowStartupLocation = WindowStartupLocation.CenterOwner;
            window.ShowDialog();
        }
    }
}
